<template>
  <div class="personnal-info">
    <div class="nav-common-title">
      <i class="el-icon-user-solid"></i>
      <span>站长简介</span>
    </div>
    <div class="nav-common-content" v-if="userInfoArr">
      <div class="personnal-info--detail" v-for="userInfo in userInfoArr" :key="userInfo" @click="jump(userInfo)">
        <div class="personnal-info--detailInfo">
          <div class="detail-img">
            <el-avatar shape="square" :size="50" :src="userInfo.avatar"></el-avatar>
          </div>
          <div class="detail-name">
            <div>{{ userInfo.name }}</div>
            <div v-if="userInfo.type">
              <el-tag v-if="userInfo.type && userInfo.type.master" effect="plain" type="warning" size="mini">
                {{ userInfo.type.master }}
                <span v-if="userInfo.id === 1">站长</span>
                <span v-else>博主</span>
              </el-tag>

              <el-tag v-if="userInfo.type && userInfo.type.name" effect="plain" type="warning" size="mini" style="margin-left: 5px">
                {{ userInfo.type.name }}
              </el-tag>
            </div>

          </div>
        </div>

        <i class="el-icon-arrow-right"></i>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      userInfoArr: null
    }
  },
  created() {
    this.getUserInfo()
  },
  methods: {
    getUserInfo() {
      this.$api.getWebmaster().then((res) => {
        if (res.code === 1) {
          this.userInfoArr = res.data
          // 技能
          // this.userInfo.skill = this.userInfo.skill.reduce((res, item) => {
          //   if (item.skill_intro && item.skill_intro.length) {
          //     res = res.concat(item.skill_intro)
          //   }
          //   return res
          // }, [])
          // console.log(this.userInfo.skill)
        }
      })
    },
    // 跳转个人简介
    jump(userInfo) {
      this.$router.push({
        name: 'MySelf',
        query: {
          uid: userInfo.name
        }
      })
    }
  }
}
</script>


<style lang="less" scoped>
.personnal-info {
  background: #fff;
  border: 1px solid #eee;

  .nav-common-content {
    padding: 15px;
  }

  .personnal-info--detailInfo {
    display: flex;
    align-items: center;
  }

  .personnal-info--detail + .personnal-info--detail {
    margin-top: 20px;
  }

  .personnal-info--detail {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;

    .detail-img {
      width: 50px;
      height: 50px;
      img {
        width: 100%;
        height: 100%;
      }
    }

    .detail-name {
      margin-left: 20px;
      font-size: 14px;

      div + div {
        margin-top: 10px;
      }
    }
  }

  .personnal-info--skill {
    margin-top: 15px;
    .skill-title {
      display: inline-block;
      font-size: 14px;
    }

    .skill-item {
      margin-left: 5px;
      margin-bottom: 5px;
    }
  }

  .personnal-info--loadmore {
    display: block;
    margin-top: 10px;
    .loadmore-btn {
      width: 100%;
    }
  }
}
</style>